package com.jf.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = {"/front/index","/front/hot","/front/about","/front/student","/front/teacher"})
public class FrontPageServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String servletPath = request.getServletPath();
        String path = "/WEB-INF/pages/front/";
        switch (servletPath){
            case "/front/index":
                path+="index.jsp";
                break;
            case "/front/hot":
                path+="hot.jsp";
                break;
            case "/front/about":
                path+="about.jsp";
                break;
            case "/front/student":
                path+="student.jsp";
                break;
            case "/front/teacher":
                path+="teacher.jsp";
                break;
        }
        request.getRequestDispatcher(path).forward(request,response);
    }
}
